package com.common.base;

import com.common.util.ValidatorUtil;

import java.util.List;

public class BaseServiceImpl<T> implements BaseService<T>{

    public BaseMapper<T> baseMapper;

    @Override
    public void setBaseMapper(BaseMapper mapper) {
        this.baseMapper = mapper;
    }

    @Override
    public T getByPrimaryKey(Object id) {
        return baseMapper.selectByPrimaryKey(id);

    }

    @Override
    public int insert(T t) {
        ValidatorUtil.validate(t);
        return baseMapper.insert(t);
    }

    @Override
    public int inserstList(List<T> t){
        return baseMapper.insertList(t);
    }

    @Override
    public int updateByPrimaryKey(T t) {
        ValidatorUtil.validate(t);
        return baseMapper.updateByPrimaryKey(t);
    }

    @Override
    public int updateByPrimaryKeySelective(T t) {
        ValidatorUtil.validate(t);
        return baseMapper.updateByPrimaryKeySelective(t);
    }

    @Override
    public int deleteByPrimaryKey(Object id) {
        return baseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<T> getList(T t) {
        return baseMapper.select(t);
    }

    @Override
    public List<T> getAll() {
        return baseMapper.selectAll();
    }
}
